package org.carl.test.dingtalk;

import org.carl.component.dingtalk.robot.annotation.EnableDingTalkRobot;
import org.carl.component.dingtalk.robot.model.TextMsgModel;
import org.carl.component.dingtalk.robot.model.link.LinkModel;
import org.carl.component.dingtalk.robot.model.link.LinkMsgModel;
import org.carl.component.dingtalk.robot.service.DingTalkService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@EnableDingTalkRobot
@SpringBootApplication
@ComponentScan(value = "org.carl.component.dingtalk")
public class DingtalkApplication {
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(DingtalkApplication.class, args);
        DingTalkService dingTalkService = applicationContext.getBean(DingTalkService.class);
        TextMsgModel msg = TextMsgModel.text("我就是我,啦啦啦");
//        DingTalkResult dingTalkResult = dingTalkService.sendReboot("1", msg);
        LinkModel lm=new LinkModel();
        lm.setText("这个即将发布的新版本，创始人xx称它为红树林。而在此之前，每当面临重大升级，产品经理们都会取一个应景的代号，这一次，为什么是红树林");
        lm.setTitle("时代的火车向前开");
        lm.setMessageUrl("https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI");
        LinkMsgModel link = LinkMsgModel.link(lm);
        dingTalkService.sendReboot("1", link);
    }
}
